package cn.iocoder.yudao.module.book.controller.app;

import java.util.List;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.book.controller.app.vo.AppBookShelfCollectVO;
import cn.iocoder.yudao.module.book.service.app.AppBookShelfCollectService;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.annotation.Resource;

@RestController
@RequestMapping("/bookShelfCollect")
public class AppBookShelfCollectController {

    @Resource
    private AppBookShelfCollectService appBookShelfCollectService;

    @GetMapping("/getListByCurrentUser")
    @Operation(summary = "获取我的收藏绘本")
    public CommonResult<List<AppBookShelfCollectVO>> getListByCurrentUser() {
        return CommonResult.success(appBookShelfCollectService.getListByCurrentUser());
    }

    @GetMapping("/collectBook/{bookId}")
    @Operation(summary = "收藏绘本/取消收藏绘本")
    public CommonResult<Boolean> collectBook(@PathVariable Long bookId, Boolean isCollect) {
        return CommonResult.success(appBookShelfCollectService.collectBook(bookId, isCollect));
    }

    @GetMapping("/isCollectBook/{bookId}")
    @Operation(summary = "查询绘本是否收藏")
    public CommonResult<Boolean> isCollectBook(@PathVariable Long bookId) {
        return CommonResult.success(appBookShelfCollectService.isCollectBook(bookId));
    }
}
